<template>
    <el-drawer v-model="drawerVisible" title="用户管理详情" direction="rtl" size="80%" :with-header="true"
        style="background: #F7F7F7;">
        <div class="header">
            <div class="header-left">
                <div class="mainimg"><img :src="rowData.userPicture" alt=""></div>
                <div class="left-title">
                    <div class="main-title">
                        <div class="name">{{ rowData.userName }}</div>
                        <div class="sub"><img src="../assets/user.png" alt=""></div>
                    </div>
                    <div class="userid">用户 ID: {{ rowData.id }}</div>
                </div>
                <div class="detail">
                    <div class="phone">
                        <p>手机号码: <text>{{ rowData.userTel }}</text></p>
                    </div>
                    <div class="time">
                        <p>注册时间: <text>{{ rowData.createTime }}</text></p>
                    </div>
                </div>
            </div>
        </div>
    </el-drawer>
</template>

<script setup>
import { ref, onMounted, onUnmounted, computed, reactive, defineProps, defineEmits, watch } from 'vue'
// 定义props接收父组件传递的数据
const props = defineProps({
    visible: {
        type: Boolean,
        default: false
    },
    rowData: {
        type: Object,
        default: () => ({})
    }
})

// 定义emit用于通知父组件drawer状态变化
const emit = defineEmits(['update:visible'])

// 抽屉可见性状态
const drawerVisible = ref(props.visible)

// 监听父组件传入的visible变化
watch(() => props.visible, (newVal) => {
    drawerVisible.value = newVal
})

// 监听drawerVisible变化并通知父组件
watch(drawerVisible, (newVal) => {
    emit('update:visible', newVal)
})

</script>

<style scoped lang="scss">
.header {
    height: 140px;
    background: #FFFFFF;
    border-radius: 10px;
    margin-top: -20px;

    .header-left {
        display: flex;
        align-items: center;

        .mainimg img {
            margin: 20px;
            width: 100px;
            height: 100px;
            border-radius: 50%;
        }

        .left-title {
            display: flex;
            flex-direction: column;
            padding-right: 60px;
            border-right: 1px solid #EEEEEE;

            .main-title {
                display: flex;
                justify-content: center;
                align-items: center;

                .name {
                    font-family: PingFang SC, PingFang SC;
                    font-weight: 600;
                    font-size: 20px;
                    color: #333333;
                    margin-right: 10px;
                }

                .sub {
                    img {
                        width: 83px;
                        height: 22px;
                    }
                }
            }

            .userid {
                font-size: 14px;
                color: #333333;
                margin-top: 10px;
            }
        }

        .detail {
            margin-left: 60px;

            .phone,
            .time {
                p {
                    font-size: 14px;
                    color: #333333;
                }

                text {
                    font-size: 14px;
                    color: #999999;
                }
            }
        }
    }


}

</style>